<!DOCTYPE html>
<html>
    <link type="text/css" rel="stylesheet" href="giftgiving.css"/>
    <!-- Uncomment the line below to include javascript in your webpage -->
    <!--<script type="text/javascript" src="giftgiving.js"/>-->
    <style type="text/css">
<!--
.STYLE1 {
	font-size: 18px;
	font-weight: bold;
}
.STYLE2 {font-size: 16px}
.STYLE3 {font-size: 18px}
-->
    </style>

    <head>
        <title>Flora Home</title>
    </head>
    <body background="elegance.gif" text="#565051">
        <div id="gift-view-id">
            <!-------  Side bars  ----------------------------------------------------------->
			<div id="gift-navpane-id" class="gift-navpane">
    			<div id="gift-pets-id" class="gift-types">
                    <a href="cus_home.php" class="STYLE1">Customer Home</a>				    </div>
				 <div id="gift-pets-id" class="gift-types">
                    <a href="admin_home.php" class="STYLE1">Admin Home</a>			</div>

                  <div id="gift-register-id" class="gift-types">
                   <a href="admin_reg.php" class="STYLE1">Admin Register</a>    			</div>
				<div id="gift-pets-id" class="gift-types">
                    <a href="admin_Profile.php" class="STYLE1">Admin Profile</a>			</div>
				<div id="gift-pets-id" class="gift-types gift-types">
                    <a href="admin_order.php" class="STYLE1">Order Info</a>			</div>
				<div id="gift-register-id" class="gift-types">
				    <a href="admin_customer.php" class="STYLE1">Customer Info</a>             </div>
				<div id="gift-register-id" class="gift-types-selected">
				    <a href="Admin_flower.php" class="STYLE1">Flower Info</a>             </div>
					<div id="gift-register-id" class="gift-types">
				    <a href="FlowersInput.php" class="STYLE1">Add Flower</a>             </div>
                <?php   
					session_start();
					if (!isset($_SESSION['SESS_CID']) || (trim($_SESSION['SESS_CID']) == '')){
						echo '<div id="gift-register-id" class="gift-types">
							  <a href="admin_login.php" class="STYLE1">Login</a>    </div>';
					}else{
						echo '<div id="gift-register-id" class="gift-types">
								  <a href="admin_login.php" class="STYLE1">Logout</a>  </div>';
					}
				?>
    		</div>
			<!--------------Main Content----------------------------------------------------->
    		<div id="gift-choosepane-id" class="gift-choosepane">
               <!-- Note the onClick handler for this element -->
               <div id="gift-table" >
        	   <table>
        			    <th colspan="3">Display  Flower Information:</th>
					  <tr> <form action="Admin_flowerselect.php" method="post">
					      <td>
                          category: 
						  </td>
						  <td>
						  <input type="text" name="category" />
						  </td>
						  <td>
						  occasion:
						  </td>
						  <td>						  
						  <select name="occasion">
						  <option value=""></option>
                          <option value="valentine">valentine</option>
                          <option value="birthday">birthday</option>
						  <option value="grand opening">grand opening</option>
						  <option value="mother day">mother day</option>
                          <option value="wedding">wedding</option></select>
						  <option value="funeral">funeral</option></select>
						  </td>
						  <td>
						  color:
						  </td>
						  <td>
						  <input type="text" name="color" />
						  </td>
						  <td>
						  size:
						  </td>
						  <td>
						  <select name="size">
						  <option value=""></option>
                          <option value="L">L</option>
                          <option value="M">M</option>
                          <option value="S">S</option></select>
						  </td>
						  <td>
						  price:
						  </td>
						  <td>
						  <select name="price">
						  <option value=""></option>
                          <option value="20"><=$20</option>
                          <option value="50"><=$50</option>
                          <option value="100"><=$100</option>
						  <option value="500"><=$500</option></select>
						  </td>
						  <td>
						  order by:
						  </td>
						  <td>
						  <select name="order">
						   <option value=""></option>
						  <option value="price asc">price low to high</option>
						  <option value="price desc"> price high to low</option>
						  <option value="size desc">size small to large</option>
						  <option value="size asc">size large to small</option>
						  </select>
						  </td>
							<td>
						  <input type="submit" value="Submit">
                          </td>
						  </form> 						  
                     </tr>	
        			<tr>
<?php
$con=mysql_connect("localhost","root","123");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }
  
 mysql_select_db("cs2102_db", $con);
 $category=$_POST["category"];
$occasion=$_POST["occasion"];
$color=$_POST["color"];
$size=$_POST["size"];
$price=$_POST["price"];
$order=$_POST["order"];

$sql = "SELECT * FROM Flowers WHERE 1 ";

if (!empty($category)) {
  $sql .= " AND category = '$category' ";
}
if (!empty($occasion)) {
  $sql .= " AND occasion= '$occasion' ";
}
if (!empty($color)) {
  $sql .= " AND color= '$color' ";
}
if (!empty($size)) {
  $sql .= " AND size= '$size' ";
}
if (!empty($price)) {
  $sql .= " AND price<= '$price' ";
}
if(!empty($order)){
$sql .=" ORDER BY $order";
}
if(!mysql_query($sql)){
  echo "Sorry, no result found!";
  exit;
}
else{
$result=mysql_query($sql);

echo "<tr>	
    <td></td>				          
    <td>name</td>
	<td>category</td>
	<td>occasion</td>
	<td>color</td>
	<td>size</td>
	<td>quantity</td>
	<td>price</td>
	</tr>";
	while ($row = mysql_fetch_array($result)){
								
		echo "<tr>";
		echo "<td> <img id='Socks' src='".$row['picture']."'/></td>";
		echo "<td>" . $row['fname'] . "</td>";
		echo "<td>" . $row['category'] . "</td>";
		echo "<td>" . $row['occasion'] . "</td>";
		echo "<td>" . $row['color'] . "</td>";
		echo "<td>" . $row['size'] . "</td>";
		echo "<td>" . $row['quantity'] . "</td>";
		echo "<td>" . $row['price']."</td>";
		echo "<form action='flo_info.php' method='post'>
		      <td> <input type='hidden' name = 'fname' value='".$row['fname']."'> </td>
			  <td> <input type='hidden' name = 'fsize' value='".$row['size']."'> </td>
			  <td> <input type='submit' value='Modify'></td>
			  </form>";
		
		echo "<form action='DeleteFlowers.php' method='post'>
		      <td> <input type='submit' value='Delete'></td>
			  <td> <input type='hidden' name = 'fname' value='".$row['fname']."'> </td>
			  <td> <input type='hidden' name = 'fsize' value='".$row['size']."'> </td>
			  </form>";
	    echo "</tr>";
	 }
}
	 mysql_close($con);
?>